package com.myexam.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.RequestAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.myexam.model.StudentResult;
import com.myexam.service.TeacherService;
import com.opensymphony.xwork2.ActionSupport;
@Controller
@Scope("prototype")
public class ShowStudentAction extends ActionSupport implements RequestAware {

	private static final long serialVersionUID = -8621866365762447278L;
	private Map<String, Object> request;
	private int studentID;
	@Autowired
	private TeacherService teacherService;
	public Map<String, Object> getRequest() {
		return request;
	}

	public void setRequest(Map<String, Object> request) {
		this.request = request;
	}

	public int getStudentID() {
		return studentID;
	}

	public void setStudentID(int studentID) {
		this.studentID = studentID;
	}
	
	public String execute()throws Exception{
		List<StudentResult> list = teacherService.studentResults(studentID);
		if(list.size()==0){
			addActionError("改同学还没有成绩的考试！");
			return INPUT;
		}else {
			request.put("Results", list);
			return SUCCESS;
		}
		
	}
	
	
}
